package com.ruoyi.delivery.service.impl;

import com.ruoyi.delivery.domain.DelDriver;
import com.ruoyi.delivery.mapper.DelDriverMapper;
import com.ruoyi.delivery.service.IDelDriverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DelDriverServiceImpl implements IDelDriverService {

    @Autowired
    private DelDriverMapper driverMapper;

    @Override
    public List<DelDriver> getDriverList(String logisticsDriver, String driverNo, String driverCity, String driverPhone,
                                         String vehicleNo, String startDate, String endDate, Integer driverState, String driverName,
                                         int offset, int pageSize) {
        return driverMapper.getDriverList(logisticsDriver, driverNo, driverCity, driverPhone, vehicleNo, startDate, endDate, driverState, driverName, offset, pageSize);
    }

    @Override
    public int getDriverCount(String logisticsDriver, String driverNo, String driverCity, String driverPhone,
                              String vehicleNo, String startDate, String endDate, Integer driverState, String driverName) {
        return driverMapper.getDriverCount(logisticsDriver, driverNo, driverCity, driverPhone, vehicleNo, startDate, endDate, driverState, driverName);
    }

    @Override
    public int updateDriverInfo(DelDriver driver) {
        return driverMapper.updateDriverInfo(driver);
    }

    @Override
    public int deleteDriver(String driverNo) {
        return driverMapper.deleteDriver(driverNo);
    }

    @Override
    public int deleteDrivers(List<String> driverNos) {
        return driverMapper.deleteDrivers(driverNos);
    }

    @Override
    public int insertDriverInfo(DelDriver driver) {
        return driverMapper.insertDriverInfo(driver);
    }

    @Override
    public DelDriver getDriverInfo(String driverNo) {
        return driverMapper.getDriverById(driverNo);
    }

    @Override
    public DelDriver getDriverByOpenId(String openId) {
        return driverMapper.getDriverByOpenId(openId);
    }

    @Override
    public boolean validateDriverNameById(String driverId, String driverName) {
        if (driverMapper.getDriverNameById(driverId) != null) {
            return driverMapper.getDriverNameById(driverId).equals(driverName);
        } else {
            return false;

        }
    }

    @Override
    public int updateDriverOpenId(String driverId, String openId){
        return driverMapper.updateDriverOpenId(driverId, openId);
    }

}

